package com.xxgc.eow.service.impl;

import com.xxgc.eow.entity.Choosetopic;
import com.xxgc.eow.mapper.ChoosetopicMapper;
import com.xxgc.eow.service.IChoosetopicService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 选择题 服务实现类
 * </p>
 *
 * @author Mr.Abel
 * @since 2023-05-18
 */
@Service
public class ChoosetopicServiceImpl extends ServiceImpl<ChoosetopicMapper, Choosetopic> implements IChoosetopicService {

    @Resource
    private ChoosetopicMapper choosetopicMapper;

    @Override
    public List<Choosetopic> getAllChooseTopic(Integer pageNum,Integer pageSize) {

        return choosetopicMapper.selectAll((pageNum-1)*pageSize,pageSize);
    }

    @Override
    public List<Choosetopic> getAllChooseTopicByLibrary(int libraryId) {
        return choosetopicMapper.selectAllByTopicLibrary(libraryId);
    }

    @Override
    public int addChooseTopic(Choosetopic choosetopic) {
        return choosetopicMapper.insert(choosetopic);
    }

    @Override
    public Choosetopic getChooseTopic(Integer chooseId) {
        return choosetopicMapper.selectByPrimaryKey(chooseId);
    }

    @Override
    public List<Choosetopic> getAllChooseTopicsByChooseTopic(Choosetopic choosetopic, Integer pageNum, Integer pageSize, String libraryName) {
        return choosetopicMapper.selectAllByChooseTopic(choosetopic, (pageNum-1)*pageSize, pageSize, libraryName);
    }

    @Override
    public Integer getCountByChooseTopic(Choosetopic choosetopic, String libraryName) {
        return choosetopicMapper.selectCountByChossseTopic(choosetopic, libraryName);
    }

    @Override
    public Integer getCountByChooseLevel(Integer chooseLevel) {
        return choosetopicMapper.selectCountByChooseLevel(chooseLevel);
    }

    @Override
    public long count() {
        return choosetopicMapper.selectCount();
    }


}
